/*
 * @Author: szx
 * @Date: 2022-04-09 15:36:02
 * @LastEditTime: 2022-04-09 15:45:27
 * @Description:
 * @FilePath: \leetcode\900-999\991\991.js
 */
/**
 * @param {number} startValue
 * @param {number} target
 * @return {number}
 */
 var brokenCalc = function (startValue, target) {
    let res = 0;
    while (target > startValue) {
        if (target & 1) target++;
        else target = Math.floor(target / 2);
        res++;
    }
    return startValue - target + res;
};
console.log(brokenCalc(2, 3));
console.log(brokenCalc(5, 8));
console.log(brokenCalc(3, 10));
